-
Notifications
You must be signed in to change notification settings - Fork 4
Build test #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build test #34
Conversation
KaushikiAnand
commented
Mar 13, 2025
- I have added unit test coverage and linting to the ci.yml workflow.
- The unit test coverage change was done to help understand the defects early in lifecycle and come up with a good solution for it. The linting was done to ensure that the codebase is consistent and maintainable and helps in improving the code quality and reducing errors.
.golangci.yml
Outdated
- errcheck | ||
disable: | ||
- unused | ||
output_format: colored-line-number No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: new lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why did we need to disable unused ?
request.go
Outdated
} | ||
if err := json.NewDecoder(buf).Decode(relationship); err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Can you check if the same pattern is happening for other error scenarios ?
I saw at some places, we are setting the value of er
and letting the flow either break or continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
followed the same pattern on suggested areas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a break
for all newly added errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added break to newly added errors
|
||
func TestHttpErrorWhenMethodDoesNotMatch(t *testing.T) { | ||
r, err := http.NewRequest(http.MethodPatch, "/blogs", nil) | ||
r, err := http.NewRequest(http.MethodOptions, "/blogs", nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is currently failing in the main branch. It is failing because previously there wasn't any handling for the method http.MethodPatch
but around an year back code was added for this case as well.
I have changed the http method to an unhandled path, so that the test case runs as expected
|
||
type OneOfMedia struct { | ||
Image *Image | ||
random int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused field
|
||
func TestUnmarshalToStructWithPointerAttr_BadType_IntSlice(t *testing.T) { | ||
out := new(WithPointer) | ||
type FooStruct struct{ A, B int } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
} | ||
videoField, ok := result["videos"] | ||
if !ok || videoField.FieldNum != 2 { | ||
if !ok || videoField.FieldNum != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unused field was removed, thus the FieldNum for videoField decreased
json.NewEncoder(buf).Encode(data.Relationships[args[1]]) //nolint:errcheck | ||
json.NewDecoder(buf).Decode(relationship) //nolint:errcheck | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: We are ignoring the lint error to preserve behaviour.